// ==UserScript==
// @name          WorkShack
// @namespace     http://gegtik.com/
// @description   Change all www.shacknews.com links to websense.shacknews.com
// @include       http://*.shacknews.com/*, http://*.lmnopc.com/*, http://*.thomwetzel.com/*
// ==/UserScript==
if (script_enabled('work_shack') == "true") 
{
    if (window.location.href.match(/www\.shacknews/i))
        window.location.href = window.location.href.replace(/www\.shacknews/i, "websense.shacknews");

    var allLinks, thisLink;
    allLinks = document.evaluate(
	    '//a[@href]',
	    document,
	    null,
	    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
	    null);

    for (var i = 0; i < allLinks.snapshotLength; i++) {
        thisLink = allLinks.snapshotItem(i);
        thisLink.href = thisLink.href.replace(/www\.shacknews/i, "websense.shacknews");
        if (thisLink.href.match(/&page=1/i) && thisLink.href.match(/websense\.shacknews\.com/i)) {
            thisLink.href = thisLink.href.substring(0, thisLink.href.indexOf("&"));
        }
    }
}
